# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Kyle Keen <keenerd@gmail.com>

_pyname=jupyter_core
pkgname=python-${_pyname/_/-}
pkgver=5.5.0
pkgrel=1
pkgdesc='Jupyter core package. A base package on which Jupyter projects rely'
arch=(any)
url='https://pypi.python.org/pypi/jupyter_core'
license=(BSD)
depends=(python
         python-argcomplete
         python-traitlets
         python-platformdirs)
makedepends=(python-build
             python-hatchling
             python-installer)
checkdepends=(python-pip
              python-pytest)
conflicts=(python-jupyter_core)
provides=(python-jupyter_core)
replaces=(python-jupyter_core)
source=(https://files.pythonhosted.org/packages/source/j/jupyter_core/$_pyname-$pkgver.tar.gz)
sha256sums=('880b86053bf298a8724994f95e99b99130659022a4f7f45f563084b6223861d3')

prepare() {
  cd $_pyname-$pkgver
  sed -e '/\/usr\/local\/share\/jupyter/d' -i jupyter_core/paths.py
}

build() {
  cd $_pyname-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd $_pyname-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest -v -W ignore::ResourceWarning
}

package() {
  cd $_pyname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
  install -Dm644 examples/jupyter-completion.bash "$pkgdir"/usr/share/bash-completion/completions/jupyter
  install -Dm644 examples/completions-zsh "$pkgdir"/usr/share/zsh/site-functions/_jupyter
}
